﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ContactSMS.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class addusertable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<long>(
                name: "ContactId",
                table: "T_MessageSession",
                type: "bigint",
                nullable: true,
                comment: "联系人id",
                oldClrType: typeof(long),
                oldType: "bigint",
                oldComment: "联系人id");

            migrationBuilder.AlterColumn<long>(
                name: "ContactId",
                table: "T_Message",
                type: "bigint",
                nullable: true,
                comment: "联系人id",
                oldClrType: typeof(long),
                oldType: "bigint",
                oldComment: "联系人id");

            migrationBuilder.CreateTable(
                name: "T_User",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false, comment: "用户id")
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    UserName = table.Column<string>(type: "VARCHAR(30)", nullable: false, comment: "用户名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    avatar = table.Column<string>(type: "VARCHAR(255)", nullable: true, comment: "头像")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PassWord = table.Column<string>(type: "VARCHAR(30)", nullable: false, comment: "密码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatTime = table.Column<long>(type: "bigint", nullable: false, comment: "创建时间"),
                    UpdateTime = table.Column<long>(type: "bigint", nullable: false, comment: "更新时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_User", x => x.Id);
                },
                comment: "用户表")
                .Annotation("MySql:CharSet", "utf8mb4");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "T_User");

            migrationBuilder.AlterColumn<long>(
                name: "ContactId",
                table: "T_MessageSession",
                type: "bigint",
                nullable: false,
                defaultValue: 0L,
                comment: "联系人id",
                oldClrType: typeof(long),
                oldType: "bigint",
                oldNullable: true,
                oldComment: "联系人id");

            migrationBuilder.AlterColumn<long>(
                name: "ContactId",
                table: "T_Message",
                type: "bigint",
                nullable: false,
                defaultValue: 0L,
                comment: "联系人id",
                oldClrType: typeof(long),
                oldType: "bigint",
                oldNullable: true,
                oldComment: "联系人id");
        }
    }
}
